package com.ggk911.pharmacy_system.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ggk911.pharmacy_system.entity.PurchaseInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author ggk-911
 * @version 1.0 2023/3/20 10:14
 */
@Repository
public interface PurchaseInfoMapper extends BaseMapper<PurchaseInfo> {

    /**
     * 增强查询，订单详情有，药品详情，供应商详情
     *
     * @param id
     * @return
     */
    PurchaseInfo selectByIdAd(Integer id);

    /**
     * 重写的selectPage方法
     *
     * @param page
     * @param queryWrapper
     * @param <P>
     * @return
     */
    <P extends IPage<PurchaseInfo>> P diyPage(P page, @Param("ew") Wrapper<PurchaseInfo> queryWrapper);

    /**
     * 通过订单编号查所有的PurchaseInfo
     *
     * @param purchaseId
     * @return
     */
    List<PurchaseInfo> getListByPurchaseId(Integer purchaseId);

    /**
     * 通过订单号和供应商提供药品号查询
     *
     * @param purchaseId
     * @param supplierDrugId
     * @return
     */
    PurchaseInfo selectByPurchaseIdAndSupplierDrugId(@Param("purchaseId") Integer purchaseId, @Param("supplierDrugId") Integer supplierDrugId);

    /**
     * 重写的selectList加强了Map
     *
     * @param queryWrapper
     * @return
     */
    List<PurchaseInfo> selectListAd(@Param("ew") Wrapper<PurchaseInfo> queryWrapper);

    /**
     * 删除整个订单的详情
     *
     * @param purchaseId
     * @return
     */
    boolean removeByPurchaseId(Integer purchaseId);

    /**
     * 处理过期
     *
     * @param id
     * @return
     */
    boolean setDrugInfoProductionDate(Integer id);

    /**
     * 拿到过期天数
     */
    int getDueDate();

    /**
     * 修改过期天数
     */
    boolean updateDueDate(Integer day);
}
